{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c7fc1a08",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import glob\n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a003ed0d",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_root = '../../datasets/MT-Dataset/images/'\n",
    "makeup_dir = os.path.join(data_root, 'makeup')\n",
    "non_makeup_dir = os.path.join(data_root, 'non-makeup')\n",
    "# 目标文件名称\n",
    "config_path = './test_tmp.txt'\n",
    "# 目标测试组数\n",
    "data_nums = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "3cc838df",
   "metadata": {},
   "outputs": [],
   "source": [
    "non_makeup_names = []\n",
    "makeup_names = []\n",
    "\n",
    "non_makeup_paths = glob.glob('%s/*' %(non_makeup_dir))\n",
    "makeup_paths = glob.glob('%s/*' %(makeup_dir))\n",
    "\n",
    "for non_makeup_path in non_makeup_paths:\n",
    "    non_makeup_name = non_makeup_path.replace(data_root, '')\n",
    "    non_makeup_names.append(non_makeup_name)\n",
    "\n",
    "for makeup_path in makeup_paths:\n",
    "    makeup_name = makeup_path.replace(data_root, '')\n",
    "    makeup_names.append(makeup_name)\n",
    "\n",
    "random.shuffle(non_makeup_names)\n",
    "random.shuffle(makeup_names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "17f2520e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "non-makeup/xfsy_0411.png makeup/vRX370.png\n",
      "\n",
      "non-makeup/vSYYZ466.png makeup/vFG239.png\n",
      "\n"
     ]
    }
   ],
   "source": [
    "with open(config_path, 'w') as f:\n",
    "    for i in range(data_nums):\n",
    "        non_makeup_name = non_makeup_names[i]\n",
    "        makeup_name = makeup_names[i]\n",
    "        line = '%s %s\\n' %(non_makeup_name, makeup_name)\n",
    "        f.write(line)\n",
    "        print(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64bb758f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "torch_1.13.1",
   "language": "python",
   "name": "torch_1.13.1"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
